package com.etrans.web.gps.business.report.controller;

import java.util.HashMap;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.etrans.web.gps.base.controller.BaseController;
import com.etrans.web.gps.business.report.domain.HistoryImgVO;
import com.etrans.web.gps.business.report.domain.HistoryPicChart;
import com.etrans.web.gps.business.report.service.HisPicService;
import com.etrans.web.gps.business.system.domain.SysUser;
import com.etrans.web.gps.business.system.service.CommonService;

/**
 * 历史图片
 * @author yin
 * 2017/06/28
 */
@Controller
@RequestMapping("/report/historyPic/*")
public class HisPicController extends BaseController{
	@Autowired
	private HisPicService hisPicService;
	@Autowired
	private CommonService commonService;
	
	@RequestMapping("pic.html")
	public String vehicleDrivingAnaOpen(){
		return "views/business/report/historyPic";
	}
	
	/**
	 * 车辆图片统计
	 * @param vehicleId
	 * @param startTime
	 * @param endTime
	 * @return
	 */
	@RequestMapping("queryChartData.html")
	@ResponseBody
	public HistoryPicChart queryChartData(String vehicleNo, String startTime, String endTime, String enterprisseId){
		HistoryPicChart chart = hisPicService.queryChartData(vehicleNo, startTime, endTime, enterprisseId);
		return chart;
	}
	
	/**
	 * 车辆图片统计
	 * @param vehicleNo
	 * @param startTime 格式：yyyy-MM-dd
	 * @param endTime 格式：yyyy-MM-dd
	 * @return
	 */
	@RequestMapping("queryPicListByVehicleNo.html")
	@ResponseBody
	public List<HistoryImgVO> queryPicListByVehicleNo(String vehicleNo, String startTime, String endTime){
		List<HistoryImgVO> picList = hisPicService.queryPicListByVehicleNo(vehicleNo, startTime, endTime);
		return picList;
	}
	
	
	/**
	 * 查询登录用户权限下的全部车辆
	 * @return  
	 */
	@ResponseBody
	@RequestMapping(value = "queryVehicleList.html")
	public List<HashMap<String,Object>> queryVehicleList(){
		SysUser user = getSysUser();
		HashMap<String,Object> param = new HashMap<>();
		param.put("FullID",user.getFullID());
		param.put("selected", "selected");
		List<HashMap<String,Object>> vehicleList=commonService.queryVeListByRole(param);
        return  vehicleList;
	}
	
}
